home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4685 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Q) include files...
  5. Date: 6 Feb 1996 14:37:36 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4f7p3g$4og@sparcserver.lrz-muenchen.de>
  9. References: <4f6lgd$smq@srvr1.engin.umich.edu>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. jykim@cobalt.engin.umich.edu (Joonyoung Kim) writes:
  13.  
  14.  
  15. >Hi. I'm kind of a beginner in C programming.
  16. >I'm trying to write a C program on SPARC under SunOS.
  17. >My problem is, it doesn't seem that I can use math functions that deal with floating point variables. For example, if I try to run following code, I get a error message.
  18.  
  19. Since you want to keep secret which "error message" you get, but you
  20. seem to get the message when you run the program, the problem seems
  21. to be that you pass an uninitialized "float" to fabs(). Since you do not
  22. assign anything to "a", the variable contains random garbage. This can
  23. lead to the expected results for some possible implementations of
  24. floating point arithmetic.
  25.  
  26. >#include <stdio.h>
  27. >#include <math.h>
  28. >main()
  29. >{
  30. >    float a,b;
  31. >    b = fabs(a);
  32. >    printf("%f",b);
  33. >}
  34.  
  35. Kurt
  36. --
  37. | Kurt Watzka                             Phone : +49-89-2180-6254
  38. | watzka@stat.uni-muenchen.de
  39. | ua302aa@sunmail.lrz-muenchen.de
  40.